﻿using System;
using System.Drawing;
using MUnit;

namespace Maze
{
    class TestCoins
    {
        SQ[,] squares = { { SQ.O, SQ.C } };
        Board board;
        Player player;
        int score;

        [Setup]
        void Setup()
        {
            this.score = -1;
            this.board = new Board(this.squares);
            this.player = new Player(new Point(0, 0), new PathFinder(this.board));
            this.player.PlayerScoreChangedEvent += new Player.PlayerScoreHandler(player_PlayerScoreChangedEvent);
            this.player.GoToSquare(new Point(1, 0));
            this.player.Update(this.board);
        }

        [Test]
        void ConsumeCoin()
        {
            Verify.Equals(SQ.O, this.board[1, 0]);
        }

        [Test]
        void IncreaseScore()
        {
            Verify.Equals(Player.StartScore + MazeForm.CoinValue - Player.MovementCost, this.player.Score);
        }

        [Test]
        void ScoreEventTriggered()
        {
            Verify.Equals(Player.StartScore + MazeForm.CoinValue - Player.MovementCost, this.score);
        }

        void player_PlayerScoreChangedEvent(int score)
        {
            this.score = score;
        }

        [TearDown]
        void TearDown()
        {
            // This will be run once after each test method
        }
    }
}
